﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    //3、蝙蝠战车的例子
    interface IExpedite
    {
        void Expedite();
    }
    interface IFly
    {
        void Fly();
    }
    interface IFire : IFly
    {
        void Fly();
        void Fire();
    }
    class Car
    {
        private string brand;
        private string type;

        public string Brand
        {
            get { return this.brand; }
            set { this.brand = value; }
        }

        public string Type
        {
            get { return this.type; }
            set { this.type = value; }
        }

        public Car(string brand, string type)
        {
            this.brand = brand;
            this.type = type;
        }

        public Car()
        {
        }
        public void Run()
        {
            Console.WriteLine("一辆品牌是{0}，型号是{1}的车在奔跑", this.brand, this.type);
        }
    }
    class Batmobile : Car, IFly,IFire,IExpedite
    {
        public void Fire()
        {
            Console.WriteLine("一辆品牌是{0}，型号是{1}的车在喷火", base.Brand, this.Type);
        }
        public void Fly()
        {
            Console.WriteLine("一辆品牌是{0}，型号是{1}的车在飞行", base.Brand, this.Type);
        }
        public void Expedite()
        {
            Console.WriteLine("一辆品牌是{0}，型号是{1}的车在加速", base.Brand, this.Type);
        }
        public Batmobile(string brand, string type) : base(brand, type)
        {

        }

    }
    class BMWCar : Car,IExpedite
    {
        public void Expedite()
        {
            Console.WriteLine("一辆品牌是{0}，型号是{1}的车在加速", base.Brand, this.Type);
        }
        public BMWCar(string brand, string type) : base(brand, type)
        {

        }
    }
    class Program2
    {
        static void TestFire(IFire fire)
        {
            fire.Fire();
        }
        static void TestFly(IFly fly)
        {
            fly.Fly();
        }
        static void TestExpedite(IExpedite expedite)
        {
            expedite.Expedite();
        }
        static void Main(string[] args)
        {
            BMWCar bmwCar1 = new BMWCar("宝马", "750");
            bmwCar1.Run();
            TestExpedite(bmwCar1);
            Console.WriteLine();
            BMWCar bmwCar2 = new BMWCar("宝马", "X5");
            bmwCar2.Run();
            TestExpedite(bmwCar2);
            Console.WriteLine();
            Batmobile batCar = new Batmobile("蝙蝠战车", "第一代");
            batCar.Run();
            batCar.Fly();
            TestExpedite(batCar);
            TestFire(batCar);
            Console.ReadKey();
        }
    }
}
